<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class CategoriesWidget extends Widget
{

    /**
     *
     * @param $data = array('cid' => 10);
     */
    public function render($data)
    {
        $categories = F('cache_categories');

        $current = $categories[$data['cid']];
        $parentID = $current['parent'];

        $brothers = array();
        foreach ($categories as $key => $value)
        {
        	if ($parentID == $value['parent'])
        	{
        		$brothers[] = $key;
        	}
        }
        $data['parent'] = $parentID;
        $data['brothers'] = $brothers;

        $tplFile = TEMPLATE_PATH .'/Home/Widget_categories.html';
        $content = $this->renderFile($tplFile, $data);
        return $content;
    }

}

/* End of file CategoriesWidget.class.php */
/* Location: ./App/Lib/Widget/CategoriesWidget.class.php */
